#include("/template/common/layout/_page_layout.html")
#@layout()

#define css()
<style>

</style>
#end

#define content()
<div class="layui-row">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>立项失败的项目</legend>
    </fieldset>
    <div class="layui-btn-group">
        #shiroHasPermission('/app/project/verfedSuccess')
        <button id="success" class="layui-btn layui-btn-small">审核通过的项目</button>
        #end

        #shiroHasPermission('/app/project/verfedDefeat')
        <button id="defeat" class="layui-btn layui-btn-small">审核未通过的项目</button>
        #end

    </div>
    <table id="dateTable" lay-filter="dateTable"></table>
</div>

<script type="text/html" id="barOption">
    #shiroHasPermission('/app/project/see')
    <a class="layui-btn layui-btn-xs" lay-event="see">查看项目资料</a>
    #end

    #shiroHasPermission('/app/project/buildProject')
    <a class="layui-btn layui-btn-xs" lay-event="build">补充资料</a>
    <a class="layui-btn layui-btn-xs" lay-event="send">发起审核</a>
    #end
</script>
#end

#define js()
<script type="text/javascript">

    layui.use(['table', 'layer'], function () {
        var table = layui.table;

        // 审核失败的表格渲染
        var tableIns = table.render({
            elem: '#dateTable'                  //指定原始表格元素选择器（推荐id选择器）
            , id: 'dateTable'
            , even: true //开启隔行背景
            , size: 'sm' //小尺寸的表格
            , height: 'full-150'    //容器高度
            , contentType: 'application/json; charset=UTF-8'
            , cols: [[                  //标题栏
                {type: 'numbers', fixed: true, unresize: 'true'}
                , {field: 'name', title: '项目名称', minWidth: 140,sort: true}
                , {field: 'roleName', title: '机构名称', minWidth: 140,sort: true}
                , {field: 'amount', title: '预计金额(单位：元)', width: 160, sort: true, templet: '#tplMoney'}
                , {field: 'brief', title: '简介', minWidth: 200, sort: true}
                , {field: 'reply', title: '审核未通过原因', minWidth: 200, sort: true}
                , {field: 'createTime', title: '创建时间', width: 150, sort: true}
                , {fixed: 'right', title: '操作', minWidth: 300, align: 'center', toolbar: '#barOption'} //这里的toolbar值是模板元素的选择器
            ]]
            , url: '#(ctxPath)/app/project/verfedDefeat'
            , method: 'get'
            , request: {
                pageName: 'pageNumber' //页码的参数名称，默认：page
                , limitName: 'pageSize' //每页数据量的参数名，默认：limit
            }
            , page: true
            , limits: [30, 60, 90, 150, 300]
            , limit: 30 //默认采用30
            , loading: true
            , done: function (res, curr, count) {
            }
        });

        $("#success").click(function () {
            window.location.href = '#(ctxPath)/app/project/toVerfedSuccess';
        });

        $("#defeat").click(function () {
            table.reload('dateTable', {
                url: '#(ctxPath)/app/project/verfedDefeat'
            });
        });

        table.on('tool(dateTable)', function (obj) {
            var data = obj.data;
            if (obj.event === 'see') {
                pop_show('查看项目资料', '#(ctxPath)/app/project/see?id=' + data.id, '1200', '750', function () {
                });
            } else if (obj.event === 'build') {
                window.location.href = '#(ctxPath)/app/project/projectMessage?id=' + data.id;
            } else if (obj.event === 'send') {
                layer.confirm('确定发起审核吗？(审核过程中不可编辑资料！)', function (index) {
                    $.post('#(ctxPath)/app/project/sendAssessment', {
                        id: data.id
                    }, function (res) {
                        if (res.status == true) {
                            layer.msg("发起审核成功！");
                            layer.close(index);
                            window.location.reload();
                        } else if (res.status == false) {
                            layer.msg("请先将项目相关资料补充完整！");
                            layer.close(index);
                        }
                    });
                });
            }
        });
    });
</script>
<script type="text/html" id="tplMoney">{{formatCurrency(d.amount)}}</script>
#end
